﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace LiveWriterBTFL
{
    public partial class frmMain : Form
    {

        PluginSettings m_settings;
        public frmMain(PluginSettings settings)
        {
            m_settings = settings;
            InitializeComponent();
            txTwitterUserName.Text = "regbac";
            txFB.Text = "regis.baccaro";
            txLinkedInUser.Text = "regisbaccaro";

        }
        
        public WindowsLive.Writer.Api.ISmartContent SelectedContent { get; set; }

        private void btnSearchTwitter_Click(object sender, EventArgs e)
        {
            PluginHelper.OpenSearch("https://twitter.com/search?q=" + txTwitterUserName.Text);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            PluginHelper.OpenSearch(PluginHelper.FB + txFB.Text);
        }

        private void button4_Click(object sender, EventArgs e)
        {
            PluginHelper.OpenSearch("http://www.linkedin.com/vsearch/f?type=all&keywords=" + txLinkedInUser.Text.Replace(" ", "+"));
        }

        private void button2_Click(object sender, EventArgs e)
        {
            
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void txTwitterUserName_TextChanged(object sender, EventArgs e)
        {
            try
            {
                MakePluginStrings();
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void MakePluginStrings()
        {
            PluginHelper ph = new PluginHelper();
            string TextToShow = ph.CreateBTFString(txTwitterUserName.Text, txFB.Text, txLinkedInUser.Text, txBlog.Text);
            string EditorText = ph.CreateBTFEditorString(txTwitterUserName.Text, txFB.Text, txLinkedInUser.Text, txBlog.Text);
            TextToShow = txPersonName.Text + " " + TextToShow;
            lblExample.Text = "Example: " + ph.Example;

            m_settings.PlaceHolder = TextToShow;

            m_settings.FinalText = EditorText;
        }

       
    }
}
